+Sat Jul 7 02:50:14 2001 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkwidget.c (gtk_widget_set_parent): Enforce
+ the widget/child realization/mapping invariants.
+
+ * gtk/gtkwidget.[ch] gtk/gtkprivate.h: Add functions
+ gtk_widget_[get/set]_child_visible() to control
+ whether visible children of a mapped window are
+ mapped.
+
+ * docs/widget_system.txt: Updated for changes in
+ container contract, and addition of GTK_CHILD_VISIBLE.
+
+ * gtk/gtkcontainer.c: Add generic map()/unmap()
+ functions that work for almost all containers.
+
+ * gtk/gtknotebook.c gtk/gtkpacker.c: Use
+ gtk_widget_set_child_visible() where necessary.
+
+ * gtk/*.c: Remove excess map(), unmap(), and
+ realization/mapping invariant enforcing code
+ from many containers.
+
Wed Jul 18 19:51:45 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextview.c (gtk_text_view_set_attributes_from_style):
- Get the foreground color from 'text', nor 'base'. (#57568)
+ Get the foreground color from 'text', nor 'fg'. (#57568)
Wed Jul 18 19:28:46 2001 Owen Taylor <otaylor@redhat.com>
+Sat Jul 7 02:50:14 2001 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkwidget.c (gtk_widget_set_parent): Enforce
+ the widget/child realization/mapping invariants.
+
+ * gtk/gtkwidget.[ch] gtk/gtkprivate.h: Add functions
+ gtk_widget_[get/set]_child_visible() to control
+ whether visible children of a mapped window are
+ mapped.
+
+ * docs/widget_system.txt: Updated for changes in
+ container contract, and addition of GTK_CHILD_VISIBLE.
+
+ * gtk/gtkcontainer.c: Add generic map()/unmap()
+ functions that work for almost all containers.
+
+ * gtk/gtknotebook.c gtk/gtkpacker.c: Use
+ gtk_widget_set_child_visible() where necessary.
+
+ * gtk/*.c: Remove excess map(), unmap(), and
+ realization/mapping invariant enforcing code
+ from many containers.
+
Wed Jul 18 19:51:45 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextview.c (gtk_text_view_set_attributes_from_style):
- Get the foreground color from 'text', nor 'base'. (#57568)
+ Get the foreground color from 'text', nor 'fg'. (#57568)
Wed Jul 18 19:28:46 2001 Owen Taylor <otaylor@redhat.com>
+Sat Jul 7 02:50:14 2001 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkwidget.c (gtk_widget_set_parent): Enforce
+ the widget/child realization/mapping invariants.
+
+ * gtk/gtkwidget.[ch] gtk/gtkprivate.h: Add functions
+ gtk_widget_[get/set]_child_visible() to control
+ whether visible children of a mapped window are
+ mapped.
+
+ * docs/widget_system.txt: Updated for changes in
+ container contract, and addition of GTK_CHILD_VISIBLE.
+
+ * gtk/gtkcontainer.c: Add generic map()/unmap()
+ functions that work for almost all containers.
+
+ * gtk/gtknotebook.c gtk/gtkpacker.c: Use
+ gtk_widget_set_child_visible() where necessary.
+
+ * gtk/*.c: Remove excess map(), unmap(), and
+ realization/mapping invariant enforcing code
+ from many containers.
+
Wed Jul 18 19:51:45 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextview.c (gtk_text_view_set_attributes_from_style):
- Get the foreground color from 'text', nor 'base'. (#57568)
+ Get the foreground color from 'text', nor 'fg'. (#57568)
Wed Jul 18 19:28:46 2001 Owen Taylor <otaylor@redhat.com>
+Sat Jul 7 02:50:14 2001 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkwidget.c (gtk_widget_set_parent): Enforce
+ the widget/child realization/mapping invariants.
+
+ * gtk/gtkwidget.[ch] gtk/gtkprivate.h: Add functions
+ gtk_widget_[get/set]_child_visible() to control
+ whether visible children of a mapped window are
+ mapped.
+
+ * docs/widget_system.txt: Updated for changes in
+ container contract, and addition of GTK_CHILD_VISIBLE.
+
+ * gtk/gtkcontainer.c: Add generic map()/unmap()
+ functions that work for almost all containers.
+
+ * gtk/gtknotebook.c gtk/gtkpacker.c: Use
+ gtk_widget_set_child_visible() where necessary.
+
+ * gtk/*.c: Remove excess map(), unmap(), and
+ realization/mapping invariant enforcing code
+ from many containers.
+
Wed Jul 18 19:51:45 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextview.c (gtk_text_view_set_attributes_from_style):
- Get the foreground color from 'text', nor 'base'. (#57568)
+ Get the foreground color from 'text', nor 'fg'. (#57568)
Wed Jul 18 19:28:46 2001 Owen Taylor <otaylor@redhat.com>
+Sat Jul 7 02:50:14 2001 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkwidget.c (gtk_widget_set_parent): Enforce
+ the widget/child realization/mapping invariants.
+
+ * gtk/gtkwidget.[ch] gtk/gtkprivate.h: Add functions
+ gtk_widget_[get/set]_child_visible() to control
+ whether visible children of a mapped window are
+ mapped.
+
+ * docs/widget_system.txt: Updated for changes in
+ container contract, and addition of GTK_CHILD_VISIBLE.
+
+ * gtk/gtkcontainer.c: Add generic map()/unmap()
+ functions that work for almost all containers.
+
+ * gtk/gtknotebook.c gtk/gtkpacker.c: Use
+ gtk_widget_set_child_visible() where necessary.
+
+ * gtk/*.c: Remove excess map(), unmap(), and
+ realization/mapping invariant enforcing code
+ from many containers.
+
Wed Jul 18 19:51:45 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextview.c (gtk_text_view_set_attributes_from_style):
- Get the foreground color from 'text', nor 'base'. (#57568)
+ Get the foreground color from 'text', nor 'fg'. (#57568)
Wed Jul 18 19:28:46 2001 Owen Taylor <otaylor@redhat.com>
+Sat Jul 7 02:50:14 2001 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkwidget.c (gtk_widget_set_parent): Enforce
+ the widget/child realization/mapping invariants.
+
+ * gtk/gtkwidget.[ch] gtk/gtkprivate.h: Add functions
+ gtk_widget_[get/set]_child_visible() to control
+ whether visible children of a mapped window are
+ mapped.
+
+ * docs/widget_system.txt: Updated for changes in
+ container contract, and addition of GTK_CHILD_VISIBLE.
+
+ * gtk/gtkcontainer.c: Add generic map()/unmap()
+ functions that work for almost all containers.
+
+ * gtk/gtknotebook.c gtk/gtkpacker.c: Use
+ gtk_widget_set_child_visible() where necessary.
+
+ * gtk/*.c: Remove excess map(), unmap(), and
+ realization/mapping invariant enforcing code
+ from many containers.
+
Wed Jul 18 19:51:45 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextview.c (gtk_text_view_set_attributes_from_style):
- Get the foreground color from 'text', nor 'base'. (#57568)
+ Get the foreground color from 'text', nor 'fg'. (#57568)
Wed Jul 18 19:28:46 2001 Owen Taylor <otaylor@redhat.com>
+Sat Jul 7 02:50:14 2001 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkwidget.c (gtk_widget_set_parent): Enforce
+ the widget/child realization/mapping invariants.
+
+ * gtk/gtkwidget.[ch] gtk/gtkprivate.h: Add functions
+ gtk_widget_[get/set]_child_visible() to control
+ whether visible children of a mapped window are
+ mapped.
+
+ * docs/widget_system.txt: Updated for changes in
+ container contract, and addition of GTK_CHILD_VISIBLE.
+
+ * gtk/gtkcontainer.c: Add generic map()/unmap()
+ functions that work for almost all containers.
+
+ * gtk/gtknotebook.c gtk/gtkpacker.c: Use
+ gtk_widget_set_child_visible() where necessary.
+
+ * gtk/*.c: Remove excess map(), unmap(), and
+ realization/mapping invariant enforcing code
+ from many containers.
+
Wed Jul 18 19:51:45 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextview.c (gtk_text_view_set_attributes_from_style):
- Get the foreground color from 'text', nor 'base'. (#57568)
+ Get the foreground color from 'text', nor 'fg'. (#57568)
Wed Jul 18 19:28:46 2001 Owen Taylor <otaylor@redhat.com>
undefined contents for the offscreen areas. In most cases, code
using gdk_image_get() should really be ported to
gdk_pixbuf_get_from_drawable().
+
+* The core GTK+ now takes care of handling mapping, unmapping and
+ realizing the child widgets of containers in
+ gtk_widget_set_parent(). In most cases, this allows container
+ implementations to be simplifid by removing the code in add()
+ methods to map and realize children. However, there are
+ a couple of things to watch out for here:
+
+ - If the parent is realized before the add() happens,
+ gtk_widget_set_parent_window() must be called before
+ gtk_widget_set_parent(), since gtk_widget_set_parent()
+ will realize the child.
+
+ - If a container depended on its children not being mapped
+ unless it did so itself (for example, GtkNotebook only
+ mapped the current page), then the new function
+ gtk_widget_set_child_visible() must be called to keep
+ widgets that should not be mapped not mapped.
+
+ As part of this change, most containers also will no longer need
+ custom implementations of the map() and unmap() virtual
+ functions. The only cases where this is necessary are:
+
+ - For !NO_WINDOW widgets, if you create children of widget->window
+ and don't map them in realize() then you must map them
+ in map(). [ In almost all cases, you can simply map the
+ windows in realize() ]
+
+ - For NO_WINDOW widgets, if you create windows in your realize()
+ method, you must map then in map() and unmap them in unmap().
#GtkRcStyle structures to form a #GtkStyle.
</para>
-@parent_instance:
@name:
@bg_pixmap_name:
@font_desc:
Set by gtk_widget_hide.
Implies that a widget is not onscreen, therefore !GTK_MAPPED.
+GTK_CHILD_VISIBLE
+ Set by gtk_widget_set_child_visible, and if FALSE indicates that
+ the widget should not be mapped even if the parent is mapped
+ and visible. Containers like GtkNotebook use this flag.
+ A private flag, not a public flag, so if you need to check
+ this flag, you should call gtk_widget_get_child_visible().
+ (Should be very rarely necesary.)
+
GTK_SENSITIVE:
Set and unset by gtk_widget_set_sensitive.
The sensitivity of a widget determines whether it will receive
5) if !GTK_WIDGET_TOPLEVEL (widget):
GTK_WIDGET_MAPPED (widget) => GTK_WIDGET_VISIBLE (widget)
+ => GTK_WIDGET_CHILD_VISIBLE (widget)
=> GTK_WIDGET_REALIZED (widget)
widget->parent && GTK_WIDGET_MAPPED (widget->parent) &&
- GTK_WIDGET_VISIBLE (widget) => GTK_WIDGET_MAPPED (widget)
+ GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_CHILD_VISIBLE
+ => GTK_WIDGET_MAPPED (widget)
Note:, the definition
When a widget is added to a container, the container:
- 1) calls gtk_widget_set_parent (widget, container)
- 2) calls gtk_widget_set_parent_window (widget, window) if
+ 1) calls gtk_widget_set_parent_window (widget, window) if
the widget is being added to something other than container->window
- 3) if container is realized, and not widget, realizes widget
- 4) if container is mapped, and not widget and widget is GTK_VISIBLE,
- maps widget
- 5) Queues a resize if the widget is mapped
-
-Note: It would be nice to remove 3) and 4) out of widget specific code
- since they are of the invariant-enforcing nature, but it is
- a bit hard, since they can't be done until after 2)
-
+ 2) calls gtk_widget_set_parent (widget, container)
Removing from a container
-------------------------
1) Set the MAPPED flag
2) If the widget has any windows, gdk_window_show those windows
3) call gtk_widget_map for all child widgets that are
- VISIBLE and !MAPPED.
+ VISIBLE, CHILD_VISIBLE and !MAPPED. (A widget will only
+ be !CHILD_VISIBLE if the container set it that way, so
+ most containers will not have to check this.)
3) Do any other functions related to putting the widget onscreen.
(for instance, showing extra popup windows...)
static void gtk_bin_class_init (GtkBinClass *klass);
static void gtk_bin_init (GtkBin *bin);
-static void gtk_bin_map (GtkWidget *widget);
-static void gtk_bin_unmap (GtkWidget *widget);
static void gtk_bin_add (GtkContainer *container,
GtkWidget *widget);
static void gtk_bin_remove (GtkContainer *container,
parent_class = gtk_type_class (GTK_TYPE_CONTAINER);
- widget_class->map = gtk_bin_map;
- widget_class->unmap = gtk_bin_unmap;
-
container_class->add = gtk_bin_add;
container_class->remove = gtk_bin_remove;
container_class->forall = gtk_bin_forall;
return GTK_TYPE_NONE;
}
-static void
-gtk_bin_map (GtkWidget *widget)
-{
- GtkBin *bin;
-
- g_return_if_fail (GTK_IS_BIN (widget));
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
- bin = GTK_BIN (widget);
-
- if (bin->child &&
- GTK_WIDGET_VISIBLE (bin->child) &&
- !GTK_WIDGET_MAPPED (bin->child))
- gtk_widget_map (bin->child);
-
- if (!GTK_WIDGET_NO_WINDOW (widget))
- gdk_window_show (widget->window);
-}
-
-static void
-gtk_bin_unmap (GtkWidget *widget)
-{
- GtkBin *bin;
-
- g_return_if_fail (GTK_IS_BIN (widget));
-
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
- bin = GTK_BIN (widget);
-
- if (!GTK_WIDGET_NO_WINDOW (widget))
- gdk_window_hide (widget->window);
-
- if (bin->child && GTK_WIDGET_MAPPED (bin->child))
- gtk_widget_unmap (bin->child);
-}
-
static void
gtk_bin_add (GtkContainer *container,
GtkWidget *child)
gtk_widget_set_parent (child, GTK_WIDGET (bin));
bin->child = child;
-
- if (GTK_WIDGET_REALIZED (child->parent))
- gtk_widget_realize (child);
-
- if (GTK_WIDGET_VISIBLE (child->parent) && GTK_WIDGET_VISIBLE (child))
- {
- if (GTK_WIDGET_MAPPED (child->parent))
- gtk_widget_map (child);
-
- gtk_widget_queue_resize (child);
- }
}
static void
guint prop_id,
GValue *value,
GParamSpec *pspec);
-static void gtk_box_map (GtkWidget *widget);
-static void gtk_box_unmap (GtkWidget *widget);
static void gtk_box_add (GtkContainer *container,
GtkWidget *widget);
static void gtk_box_remove (GtkContainer *container,
gobject_class->set_property = gtk_box_set_property;
gobject_class->get_property = gtk_box_get_property;
- widget_class->map = gtk_box_map;
- widget_class->unmap = gtk_box_unmap;
-
container_class->add = gtk_box_add;
container_class->remove = gtk_box_remove;
container_class->forall = gtk_box_forall;
gtk_widget_set_parent (child, GTK_WIDGET (box));
- if (GTK_WIDGET_REALIZED (box))
- gtk_widget_realize (child);
-
- if (GTK_WIDGET_VISIBLE (box) && GTK_WIDGET_VISIBLE (child))
- {
- if (GTK_WIDGET_MAPPED (box))
- gtk_widget_map (child);
-
- gtk_widget_queue_resize (child);
- }
gtk_widget_child_notify (child, "expand");
gtk_widget_child_notify (child, "fill");
gtk_widget_child_notify (child, "padding");
gtk_widget_set_parent (child, GTK_WIDGET (box));
- if (GTK_WIDGET_REALIZED (box))
- gtk_widget_realize (child);
-
- if (GTK_WIDGET_VISIBLE (box) && GTK_WIDGET_VISIBLE (child))
- {
- if (GTK_WIDGET_MAPPED (box))
- gtk_widget_map (child);
-
- gtk_widget_queue_resize (child);
- }
gtk_widget_child_notify (child, "expand");
gtk_widget_child_notify (child, "fill");
gtk_widget_child_notify (child, "padding");
gtk_widget_thaw_child_notify (child);
}
-static void
-gtk_box_map (GtkWidget *widget)
-{
- GtkBox *box;
- GtkBoxChild *child;
- GList *children;
-
- g_return_if_fail (GTK_IS_BOX (widget));
-
- box = GTK_BOX (widget);
- GTK_WIDGET_SET_FLAGS (box, GTK_MAPPED);
-
- children = box->children;
- while (children)
- {
- child = children->data;
- children = children->next;
-
- if (GTK_WIDGET_VISIBLE (child->widget) &&
- !GTK_WIDGET_MAPPED (child->widget))
- gtk_widget_map (child->widget);
- }
-}
-
-static void
-gtk_box_unmap (GtkWidget *widget)
-{
- GtkBox *box;
- GtkBoxChild *child;
- GList *children;
-
- g_return_if_fail (GTK_IS_BOX (widget));
-
- box = GTK_BOX (widget);
- GTK_WIDGET_UNSET_FLAGS (box, GTK_MAPPED);
-
- children = box->children;
- while (children)
- {
- child = children->data;
- children = children->next;
-
- if (GTK_WIDGET_VISIBLE (child->widget) &&
- GTK_WIDGET_MAPPED (child->widget))
- gtk_widget_unmap (child->widget);
- }
-}
-
static void
gtk_box_add (GtkContainer *container,
GtkWidget *widget)
static void gtk_container_hide_all (GtkWidget *widget);
static gint gtk_container_expose (GtkWidget *widget,
GdkEventExpose *event);
+static void gtk_container_map (GtkWidget *widget);
+static void gtk_container_unmap (GtkWidget *widget);
+
static gchar* gtk_container_child_default_composite_name (GtkContainer *container,
GtkWidget *child);
widget_class->show_all = gtk_container_show_all;
widget_class->hide_all = gtk_container_hide_all;
widget_class->expose_event = gtk_container_expose;
+ widget_class->map = gtk_container_map;
+ widget_class->unmap = gtk_container_unmap;
widget_class->focus = gtk_container_focus;
class->add = gtk_container_add_unimplemented;
return TRUE;
}
+static void
+gtk_container_map_child (GtkWidget *child,
+ gpointer client_data)
+{
+ if (GTK_WIDGET_VISIBLE (child) &&
+ GTK_WIDGET_CHILD_VISIBLE (child) &&
+ !GTK_WIDGET_MAPPED (child))
+ gtk_widget_map (child);
+}
+
+static void
+gtk_container_map (GtkWidget *widget)
+{
+ GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
+
+ gtk_container_forall (GTK_CONTAINER (widget),
+ gtk_container_map_child,
+ NULL);
+
+ if (!GTK_WIDGET_NO_WINDOW (widget))
+ gdk_window_show (widget->window);
+}
+
+static void
+gtk_container_unmap (GtkWidget *widget)
+{
+ GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
+
+ if (!GTK_WIDGET_NO_WINDOW (widget))
+ gdk_window_hide (widget->window);
+ else
+ gtk_container_forall (GTK_CONTAINER (widget),
+ (GtkCallback)gtk_widget_unmap,
+ NULL);
+}
/**
* gtk_container_propagate_expose:
GtkWidget *child,
const gchar *property_name,
GValue *value);
-
#define GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID(object, property_id, pspec) \
G_OBJECT_WARN_INVALID_PSPEC ((object), "child property id", (property_id), (pspec))
static void gtk_fixed_class_init (GtkFixedClass *klass);
static void gtk_fixed_init (GtkFixed *fixed);
-static void gtk_fixed_map (GtkWidget *widget);
static void gtk_fixed_realize (GtkWidget *widget);
static void gtk_fixed_size_request (GtkWidget *widget,
GtkRequisition *requisition);
parent_class = gtk_type_class (GTK_TYPE_CONTAINER);
- widget_class->map = gtk_fixed_map;
widget_class->realize = gtk_fixed_realize;
widget_class->size_request = gtk_fixed_size_request;
widget_class->size_allocate = gtk_fixed_size_allocate;
gtk_widget_set_parent (widget, GTK_WIDGET (fixed));
fixed->children = g_list_append (fixed->children, child_info);
-
- if (GTK_WIDGET_REALIZED (fixed))
- gtk_widget_realize (widget);
-
- if (GTK_WIDGET_VISIBLE (fixed) && GTK_WIDGET_VISIBLE (widget))
- {
- if (GTK_WIDGET_MAPPED (fixed))
- gtk_widget_map (widget);
-
- gtk_widget_queue_resize (GTK_WIDGET (fixed));
- }
}
void
}
}
-static void
-gtk_fixed_map (GtkWidget *widget)
-{
- GtkFixed *fixed;
- GtkFixedChild *child;
- GList *children;
-
- g_return_if_fail (GTK_IS_FIXED (widget));
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
- fixed = GTK_FIXED (widget);
-
- children = fixed->children;
- while (children)
- {
- child = children->data;
- children = children->next;
-
- if (GTK_WIDGET_VISIBLE (child->widget) &&
- !GTK_WIDGET_MAPPED (child->widget))
- gtk_widget_map (child->widget);
- }
-
- gdk_window_show (widget->window);
-}
-
static void
gtk_fixed_realize (GtkWidget *widget)
{
GtkRequisition *requisition);
static void gtk_frame_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
-static void gtk_frame_map (GtkWidget *widget);
-static void gtk_frame_unmap (GtkWidget *widget);
static void gtk_frame_remove (GtkContainer *container,
GtkWidget *child);
static void gtk_frame_forall (GtkContainer *container,
widget_class->expose_event = gtk_frame_expose;
widget_class->size_request = gtk_frame_size_request;
widget_class->size_allocate = gtk_frame_size_allocate;
- widget_class->map = gtk_frame_map;
- widget_class->unmap = gtk_frame_unmap;
container_class->remove = gtk_frame_remove;
container_class->forall = gtk_frame_forall;
}
}
-static void
-gtk_frame_map (GtkWidget *widget)
-{
- GtkFrame *frame = GTK_FRAME (widget);
-
- if (frame->label_widget &&
- GTK_WIDGET_VISIBLE (frame->label_widget) &&
- !GTK_WIDGET_MAPPED (frame->label_widget))
- gtk_widget_map (frame->label_widget);
-
- if (GTK_WIDGET_CLASS (parent_class)->map)
- (* GTK_WIDGET_CLASS (parent_class)->map) (widget);
-}
-
-static void
-gtk_frame_unmap (GtkWidget *widget)
-{
- GtkFrame *frame = GTK_FRAME (widget);
-
- if (GTK_WIDGET_CLASS (parent_class)->unmap)
- (* GTK_WIDGET_CLASS (parent_class)->unmap) (widget);
-
- if (frame->label_widget && GTK_WIDGET_MAPPED (frame->label_widget))
- gtk_widget_unmap (frame->label_widget);
-}
-
static void
gtk_frame_compute_child_allocation (GtkFrame *frame,
GtkAllocation *child_allocation)
static void gtk_hsv_class_init (GtkHSVClass *class);
static void gtk_hsv_init (GtkHSV *hsv);
static void gtk_hsv_destroy (GtkObject *object);
-static void gtk_hsv_map (GtkWidget *widget);
-static void gtk_hsv_unmap (GtkWidget *widget);
static void gtk_hsv_realize (GtkWidget *widget);
static void gtk_hsv_unrealize (GtkWidget *widget);
static void gtk_hsv_size_request (GtkWidget *widget,
object_class->destroy = gtk_hsv_destroy;
- widget_class->map = gtk_hsv_map;
- widget_class->unmap = gtk_hsv_unmap;
widget_class->realize = gtk_hsv_realize;
widget_class->unrealize = gtk_hsv_unrealize;
widget_class->size_request = gtk_hsv_size_request;
/* Default signal handlers */
-/* Map handler for the HSV color selector */
-static void
-gtk_hsv_map (GtkWidget *widget)
-{
- GtkHSV *hsv;
- HSVPrivate *priv;
-
- hsv = GTK_HSV (widget);
- priv = hsv->priv;
-
- if (GTK_WIDGET_MAPPED (widget))
- return;
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
-
- gdk_window_show (priv->window);
-}
-
-/* Unmap handler for the HSV color selector */
-static void
-gtk_hsv_unmap (GtkWidget *widget)
-{
- GtkHSV *hsv;
- HSVPrivate *priv;
-
- hsv = GTK_HSV (widget);
- priv = hsv->priv;
-
- if (!GTK_WIDGET_MAPPED (widget))
- return;
-
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
-
- gdk_window_hide (priv->window);
-}
-
/* Realize handler for the HSV color selector */
static void
gtk_hsv_realize (GtkWidget *widget)
static void gtk_image_menu_item_toggle_size_request (GtkMenuItem *menu_item,
gint *requisition);
-static void gtk_image_menu_item_map (GtkWidget *widget);
-static void gtk_image_menu_item_unmap (GtkWidget *widget);
static void gtk_image_menu_item_forall (GtkContainer *container,
gboolean include_internals,
GtkCallback callback,
widget_class->size_request = gtk_image_menu_item_size_request;
widget_class->size_allocate = gtk_image_menu_item_size_allocate;
- widget_class->map = gtk_image_menu_item_map;
- widget_class->unmap = gtk_image_menu_item_unmap;
container_class->forall = gtk_image_menu_item_forall;
container_class->remove = gtk_image_menu_item_remove;
}
}
-static void
-gtk_image_menu_item_map (GtkWidget *widget)
-{
- GtkImageMenuItem *image_menu_item;
-
- g_return_if_fail (GTK_IS_IMAGE_MENU_ITEM (widget));
-
- image_menu_item = GTK_IMAGE_MENU_ITEM (widget);
-
- (* GTK_WIDGET_CLASS (parent_class)->map) (widget);
-
- if (image_menu_item->image &&
- GTK_WIDGET_VISIBLE (image_menu_item->image) &&
- !GTK_WIDGET_MAPPED (image_menu_item->image))
- gtk_widget_map (image_menu_item->image);
-
- if (!GTK_WIDGET_NO_WINDOW (widget))
- gdk_window_show (widget->window);
-}
-
-static void
-gtk_image_menu_item_unmap (GtkWidget *widget)
-{
- GtkImageMenuItem *image_menu_item;
-
- g_return_if_fail (GTK_IS_IMAGE_MENU_ITEM (widget));
-
- image_menu_item = GTK_IMAGE_MENU_ITEM (widget);
-
- (* GTK_WIDGET_CLASS (parent_class)->unmap) (widget);
-
- if (!GTK_WIDGET_NO_WINDOW (widget))
- gdk_window_hide (widget->window);
-
- if (image_menu_item->image && GTK_WIDGET_MAPPED (image_menu_item->image))
- gtk_widget_unmap (image_menu_item->image);
-}
-
static void
gtk_image_menu_item_forall (GtkContainer *container,
gboolean include_internals,
gtk_widget_set_parent (image, GTK_WIDGET (image_menu_item));
g_object_notify (G_OBJECT (image_menu_item), "image");
-
- if (GTK_WIDGET_REALIZED (image->parent))
- gtk_widget_realize (image);
-
- if (GTK_WIDGET_VISIBLE (image->parent) && GTK_WIDGET_VISIBLE (image))
- {
- if (GTK_WIDGET_MAPPED (image->parent))
- gtk_widget_map (image);
-
- gtk_widget_queue_resize (image);
- }
}
GtkWidget*
static void gtk_item_class_init (GtkItemClass *klass);
static void gtk_item_init (GtkItem *item);
-static void gtk_item_map (GtkWidget *widget);
-static void gtk_item_unmap (GtkWidget *widget);
static void gtk_item_realize (GtkWidget *widget);
static gint gtk_item_enter (GtkWidget *widget,
GdkEventCrossing *event);
widget_class = (GtkWidgetClass*) class;
- widget_class->map = gtk_item_map;
- widget_class->unmap = gtk_item_unmap;
widget_class->realize = gtk_item_realize;
widget_class->enter_notify_event = gtk_item_enter;
widget_class->leave_notify_event = gtk_item_leave;
}
-static void
-gtk_item_map (GtkWidget *widget)
-{
- GtkBin *bin;
-
- g_return_if_fail (GTK_IS_ITEM (widget));
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
-
- bin = GTK_BIN (widget);
-
- if (bin->child &&
- GTK_WIDGET_VISIBLE (bin->child) &&
- !GTK_WIDGET_MAPPED (bin->child))
- gtk_widget_map (bin->child);
-
- gdk_window_show (widget->window);
-}
-
-static void
-gtk_item_unmap (GtkWidget *widget)
-{
- g_return_if_fail (GTK_IS_ITEM (widget));
-
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
-
- gdk_window_hide (widget->window);
-}
-
static void
gtk_item_realize (GtkWidget *widget)
{
layout->children = g_list_append (layout->children, child);
- gtk_widget_set_parent (child_widget, GTK_WIDGET (layout));
if (GTK_WIDGET_REALIZED (layout))
gtk_widget_set_parent_window (child->widget, layout->bin_window);
-
- if (GTK_WIDGET_REALIZED (layout))
- gtk_widget_realize (child_widget);
-
- if (GTK_WIDGET_VISIBLE (layout) && GTK_WIDGET_VISIBLE (child_widget))
- {
- if (GTK_WIDGET_MAPPED (layout))
- gtk_widget_map (child_widget);
-
- gtk_widget_queue_resize (child_widget);
- }
+
+ gtk_widget_set_parent (child_widget, GTK_WIDGET (layout));
}
void
static void gtk_list_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void gtk_list_realize (GtkWidget *widget);
-static void gtk_list_map (GtkWidget *widget);
static void gtk_list_unmap (GtkWidget *widget);
static void gtk_list_style_set (GtkWidget *widget,
GtkStyle *previous_style);
object_class->set_arg = gtk_list_set_arg;
object_class->get_arg = gtk_list_get_arg;
- widget_class->map = gtk_list_map;
widget_class->unmap = gtk_list_unmap;
widget_class->style_set = gtk_list_style_set;
widget_class->realize = gtk_list_realize;
* gtk_list_size_request
* gtk_list_size_allocate
* gtk_list_realize
- * gtk_list_map
* gtk_list_unmap
* gtk_list_motion_notify
* gtk_list_button_press
&widget->style->base[GTK_STATE_NORMAL]);
}
-static void
-gtk_list_map (GtkWidget *widget)
-{
- GtkList *list;
- GtkWidget *child;
- GList *children;
-
- g_return_if_fail (GTK_IS_LIST (widget));
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
- list = GTK_LIST (widget);
-
- children = list->children;
- while (children)
- {
- child = children->data;
- children = children->next;
-
- if (GTK_WIDGET_VISIBLE (child) &&
- !GTK_WIDGET_MAPPED (child))
- gtk_widget_map (child);
- }
-
- gdk_window_show (widget->window);
-}
-
static void
gtk_list_unmap (GtkWidget *widget)
{
gtk_signal_connect (GTK_OBJECT (widget), "toggle",
GTK_SIGNAL_FUNC (gtk_list_signal_item_toggle),
list);
-
- if (GTK_WIDGET_REALIZED (widget->parent))
- gtk_widget_realize (widget);
-
- if (GTK_WIDGET_VISIBLE (widget->parent) && GTK_WIDGET_VISIBLE (widget))
- {
- if (GTK_WIDGET_MAPPED (widget->parent))
- gtk_widget_map (widget);
-
- gtk_widget_queue_resize (widget);
- }
}
GtkWidget *child,
gint position)
{
- GTK_MENU_SHELL_CLASS (parent_class)->insert (menu_shell, child, position);
+ if (GTK_WIDGET_REALIZED (menu_shell))
+ gtk_widget_set_parent_window (child, GTK_MENU (menu_shell)->bin_window);
- gtk_widget_set_parent_window (child, GTK_MENU (menu_shell)->bin_window);
+ GTK_MENU_SHELL_CLASS (parent_class)->insert (menu_shell, child, position);
}
static void
static void gtk_menu_shell_class_init (GtkMenuShellClass *klass);
static void gtk_menu_shell_init (GtkMenuShell *menu_shell);
-static void gtk_menu_shell_map (GtkWidget *widget);
static void gtk_menu_shell_realize (GtkWidget *widget);
static gint gtk_menu_shell_button_press (GtkWidget *widget,
GdkEventButton *event);
parent_class = gtk_type_class (gtk_container_get_type ());
- widget_class->map = gtk_menu_shell_map;
widget_class->realize = gtk_menu_shell_realize;
widget_class->button_press_event = gtk_menu_shell_button_press;
widget_class->button_release_event = gtk_menu_shell_button_release;
menu_shell->children = g_list_insert (menu_shell->children, child, position);
gtk_widget_set_parent (child, GTK_WIDGET (menu_shell));
-
- if (GTK_WIDGET_REALIZED (child->parent))
- gtk_widget_realize (child);
-
- if (GTK_WIDGET_VISIBLE (child->parent) && GTK_WIDGET_VISIBLE (child))
- {
- if (GTK_WIDGET_MAPPED (child->parent))
- gtk_widget_map (child);
-
- gtk_widget_queue_resize (child);
- }
}
void
gtk_signal_emit (GTK_OBJECT (menu_shell), menu_shell_signals[DEACTIVATE]);
}
-static void
-gtk_menu_shell_map (GtkWidget *widget)
-{
- GtkMenuShell *menu_shell;
- GtkWidget *child;
- GList *children;
-
- g_return_if_fail (GTK_IS_MENU_SHELL (widget));
-
- menu_shell = GTK_MENU_SHELL (widget);
- GTK_WIDGET_SET_FLAGS (menu_shell, GTK_MAPPED);
-
- children = menu_shell->children;
- while (children)
- {
- child = children->data;
- children = children->next;
-
- if (GTK_WIDGET_VISIBLE (child) && !GTK_WIDGET_MAPPED (child))
- gtk_widget_map (child);
- }
-
- gdk_window_show (widget->window);
-}
-
static void
gtk_menu_shell_realize (GtkWidget *widget)
{
static gint gtk_notebook_focus_in (GtkWidget *widget,
GdkEventFocus *event);
static void gtk_notebook_draw_focus (GtkWidget *widget);
-static void gtk_notebook_style_set (GtkWidget *widget,
- GtkStyle *previous_style);
static gint gtk_notebook_focus (GtkWidget *widget,
GtkDirectionType direction);
widget_class->leave_notify_event = gtk_notebook_leave_notify;
widget_class->motion_notify_event = gtk_notebook_motion_notify;
widget_class->focus_in_event = gtk_notebook_focus_in;
- widget_class->style_set = gtk_notebook_style_set;
widget_class->focus = gtk_notebook_focus;
container_class->add = gtk_notebook_add;
widget->requisition.height = MAX (widget->requisition.height,
child_requisition.height);
- if (GTK_WIDGET_MAPPED (page->child) && page != notebook->cur_page)
- gtk_widget_unmap (page->child);
if (notebook->menu && page->menu_label->parent &&
!GTK_WIDGET_VISIBLE (page->menu_label->parent))
gtk_widget_show (page->menu_label->parent);
}
}
-static void
-gtk_notebook_style_set (GtkWidget *widget,
- GtkStyle *previous_style)
-{
- if (GTK_WIDGET_REALIZED (widget) &&
- !GTK_WIDGET_NO_WINDOW (widget))
- {
- gtk_style_set_background (widget->style, widget->window, widget->state);
- if (GTK_WIDGET_DRAWABLE (widget))
- gdk_window_clear (widget->window);
- }
-
- gtk_notebook_set_shape (GTK_NOTEBOOK(widget));
-}
-
/* Private GtkContainer Methods :
*
* gtk_notebook_set_child_arg
while (children)
{
page = children->data;
- if (GTK_WIDGET_MAPPED (page->tab_label))
+ if (gtk_widget_get_child_visible (page->tab_label))
{
x = page->allocation.x;
y = page->allocation.y;
STEP_NEXT, TRUE))
{
page = children->data;
- if (page->tab_label && GTK_WIDGET_MAPPED (page->tab_label))
- gtk_widget_unmap (page->tab_label);
+ if (page->tab_label)
+ gtk_widget_set_child_visible (page->tab_label, FALSE);
}
for (children = last_child; children;
children = gtk_notebook_search_page (notebook, children,
STEP_NEXT, TRUE))
{
page = children->data;
- if (page->tab_label && GTK_WIDGET_MAPPED (page->tab_label))
- gtk_widget_unmap (page->tab_label);
+ if (page->tab_label)
+ gtk_widget_set_child_visible (page->tab_label, FALSE);
}
}
else /* !showarrow */
break;
}
- if (GTK_WIDGET_REALIZED (notebook) &&
- page->tab_label && !GTK_WIDGET_MAPPED (page->tab_label))
- {
- if (GTK_WIDGET_VISIBLE (page->tab_label))
- gtk_widget_map (page->tab_label);
- else
- gtk_widget_show (page->tab_label);
- }
+ if (page->tab_label)
+ gtk_widget_set_child_visible (page->tab_label, TRUE);
}
if (children)
break;
}
- if (GTK_WIDGET_REALIZED (notebook) && page->tab_label &&
- !GTK_WIDGET_MAPPED (page->tab_label))
- {
- if (GTK_WIDGET_VISIBLE (page->tab_label))
- gtk_widget_map (page->tab_label);
- else
- gtk_widget_show (page->tab_label);
- }
+ if (page->tab_label)
+ gtk_widget_set_child_visible (page->tab_label, TRUE);
}
}
if (notebook->cur_page == page || !GTK_WIDGET_VISIBLE (page->child))
return;
- if (notebook->cur_page && GTK_WIDGET_MAPPED (notebook->cur_page->child))
- gtk_widget_unmap (notebook->cur_page->child);
+ if (notebook->cur_page)
+ gtk_widget_set_child_visible (notebook->cur_page->child, FALSE);
notebook->cur_page = page;
notebook->focus_tab =
g_list_find (notebook->children, notebook->cur_page);
- if (GTK_WIDGET_MAPPED (notebook))
- gtk_widget_map (notebook->cur_page->child);
+ gtk_widget_set_child_visible (notebook->cur_page->child, TRUE);
gtk_widget_queue_resize (GTK_WIDGET (notebook));
g_object_notify (G_OBJECT (notebook), "page");
if (!notebook->first_tab)
notebook->first_tab = notebook->children;
+ if (!notebook->cur_page)
+ gtk_widget_set_child_visible (child, TRUE);
+ else
+ gtk_widget_set_child_visible (child, FALSE);
+
+ if (tab_label)
+ {
+ if (notebook->show_tabs && GTK_WIDGET_VISIBLE (child))
+ gtk_widget_show (tab_label);
+ else
+ gtk_widget_hide (tab_label);
+ }
+
gtk_widget_set_parent (child, GTK_WIDGET (notebook));
if (tab_label)
gtk_widget_set_parent (tab_label, GTK_WIDGET (notebook));
gtk_notebook_switch_focus_tab (notebook, NULL);
}
- if (GTK_WIDGET_REALIZED (child->parent))
- gtk_widget_realize (child);
-
- if (GTK_WIDGET_VISIBLE (notebook))
- {
- if (GTK_WIDGET_VISIBLE (child))
- {
- if (GTK_WIDGET_MAPPED (notebook) &&
- !GTK_WIDGET_MAPPED (child) &&
- notebook->cur_page == page)
- gtk_widget_map (child);
-
- gtk_widget_queue_resize (child);
- }
-
- if (tab_label)
- {
- if (notebook->show_tabs && GTK_WIDGET_VISIBLE (child))
- {
- if (!GTK_WIDGET_VISIBLE (tab_label))
- gtk_widget_show (tab_label);
-
- if (GTK_WIDGET_REALIZED (notebook) &&
- !GTK_WIDGET_REALIZED (tab_label))
- gtk_widget_realize (tab_label);
-
- if (GTK_WIDGET_MAPPED (notebook) &&
- !GTK_WIDGET_MAPPED (tab_label))
- gtk_widget_map (tab_label);
- }
- else if (GTK_WIDGET_VISIBLE (tab_label))
- gtk_widget_hide (tab_label);
- }
- }
-
if (tab_label)
page->mnemonic_activate_signal =
gtk_signal_connect (GTK_OBJECT (tab_label),
static void gtk_packer_class_init (GtkPackerClass *klass);
static void gtk_packer_init (GtkPacker *packer);
-static void gtk_packer_map (GtkWidget *widget);
-static void gtk_packer_unmap (GtkWidget *widget);
static void gtk_packer_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void gtk_packer_size_allocate (GtkWidget *widget,
gobject_class->set_property = gtk_packer_set_property;
gobject_class->get_property = gtk_packer_get_property;
- widget_class->map = gtk_packer_map;
- widget_class->unmap = gtk_packer_unmap;
-
widget_class->size_request = gtk_packer_size_request;
widget_class->size_allocate = gtk_packer_size_allocate;
packer->children = g_list_append(packer->children, (gpointer) pchild);
gtk_widget_set_parent (child, GTK_WIDGET (packer));
-
- if (GTK_WIDGET_REALIZED (child->parent))
- gtk_widget_realize (child);
-
- if (GTK_WIDGET_VISIBLE (child->parent) && GTK_WIDGET_VISIBLE (child))
- {
- if (GTK_WIDGET_MAPPED (child->parent))
- gtk_widget_map (child);
-
- gtk_widget_queue_resize (child);
- }
}
void
packer->children = g_list_append(packer->children, (gpointer) pchild);
gtk_widget_set_parent (child, GTK_WIDGET (packer));
-
- if (GTK_WIDGET_REALIZED (child->parent))
- gtk_widget_realize (child);
-
- if (GTK_WIDGET_VISIBLE (child->parent) && GTK_WIDGET_VISIBLE (child))
- {
- if (GTK_WIDGET_MAPPED (child->parent))
- gtk_widget_map (child);
-
- gtk_widget_queue_resize (child);
- }
}
void
}
}
-static void
-gtk_packer_map (GtkWidget *widget)
-{
- GtkPacker *packer;
- GtkPackerChild *child;
- GList *children;
-
- g_return_if_fail (GTK_IS_PACKER (widget));
-
- packer = GTK_PACKER (widget);
- GTK_WIDGET_SET_FLAGS (packer, GTK_MAPPED);
-
- children = g_list_first(packer->children);
- while (children != NULL)
- {
- child = children->data;
- children = g_list_next(children);
-
- if (GTK_WIDGET_VISIBLE (child->widget) &&
- !GTK_WIDGET_MAPPED (child->widget))
- gtk_widget_map (child->widget);
- }
-}
-
-static void
-gtk_packer_unmap (GtkWidget *widget)
-{
- GtkPacker *packer;
- GtkPackerChild *child;
- GList *children;
-
- g_return_if_fail (GTK_IS_PACKER (widget));
-
- packer = GTK_PACKER (widget);
- GTK_WIDGET_UNSET_FLAGS (packer, GTK_MAPPED);
-
- children = g_list_first(packer->children);
- while (children)
- {
- child = children->data;
- children = g_list_next(children);
-
- if (GTK_WIDGET_VISIBLE (child->widget) &&
- GTK_WIDGET_MAPPED (child->widget))
- gtk_widget_unmap (child->widget);
- }
-}
-
static void
gtk_packer_size_request (GtkWidget *widget,
GtkRequisition *requisition)
if (width <= 0 || height <= 0)
{
- gtk_widget_unmap(child->widget);
+ gtk_widget_set_child_visible (child->widget, FALSE);
}
else
{
child_allocation.height = height;
gtk_widget_size_allocate (child->widget, &child_allocation);
- if (GTK_WIDGET_MAPPED (widget) &&
- !(GTK_WIDGET_MAPPED (child->widget)))
- gtk_widget_map(child->widget);
+ gtk_widget_set_child_visible (child->widget, TRUE);
}
list = g_list_next(list);
GValue *value,
GParamSpec *pspec);
static void gtk_paned_realize (GtkWidget *widget);
-static void gtk_paned_map (GtkWidget *widget);
-static void gtk_paned_unmap (GtkWidget *widget);
static void gtk_paned_unrealize (GtkWidget *widget);
static gint gtk_paned_expose (GtkWidget *widget,
GdkEventExpose *event);
object_class->get_property = gtk_paned_get_property;
widget_class->realize = gtk_paned_realize;
- widget_class->map = gtk_paned_map;
- widget_class->unmap = gtk_paned_unmap;
widget_class->unrealize = gtk_paned_unrealize;
widget_class->expose_event = gtk_paned_expose;
gdk_window_show (paned->handle);
}
-static void
-gtk_paned_map (GtkWidget *widget)
-{
- GtkPaned *paned;
-
- g_return_if_fail (GTK_IS_PANED (widget));
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
- paned = GTK_PANED (widget);
-
- if (paned->child1 &&
- GTK_WIDGET_VISIBLE (paned->child1) &&
- !GTK_WIDGET_MAPPED (paned->child1))
- gtk_widget_map (paned->child1);
- if (paned->child2 &&
- GTK_WIDGET_VISIBLE (paned->child2) &&
- !GTK_WIDGET_MAPPED (paned->child2))
- gtk_widget_map (paned->child2);
-
- gdk_window_show (widget->window);
-}
-
-static void
-gtk_paned_unmap (GtkWidget *widget)
-{
- g_return_if_fail (GTK_IS_PANED (widget));
-
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
-
- gdk_window_hide (widget->window);
-}
-
static void
gtk_paned_unrealize (GtkWidget *widget)
{
paned->child1_shrink = shrink;
gtk_widget_set_parent (child, GTK_WIDGET (paned));
-
- if (GTK_WIDGET_REALIZED (child->parent))
- gtk_widget_realize (child);
-
- if (GTK_WIDGET_VISIBLE (child->parent) && GTK_WIDGET_VISIBLE (child))
- {
- if (GTK_WIDGET_MAPPED (child->parent))
- gtk_widget_map (child);
-
- gtk_widget_queue_resize (child);
- }
}
}
paned->child2_shrink = shrink;
gtk_widget_set_parent (child, GTK_WIDGET (paned));
-
- if (GTK_WIDGET_REALIZED (child->parent))
- gtk_widget_realize (child);
-
- if (GTK_WIDGET_VISIBLE (child->parent) && GTK_WIDGET_VISIBLE (child))
- {
- if (GTK_WIDGET_MAPPED (child->parent))
- gtk_widget_map (child);
-
- gtk_widget_queue_resize (child);
- }
}
}
plug->same_app = TRUE;
socket->plug_widget = widget;
- gtk_widget_set_parent (widget, GTK_WIDGET (socket));
-
if (GTK_WIDGET_REALIZED (widget))
gdk_window_reparent (widget->window, plug->socket_window, 0, 0);
- else
- gtk_widget_realize (widget);
- if (GTK_WIDGET_VISIBLE (socket) && GTK_WIDGET_VISIBLE (widget))
- {
- if (GTK_WIDGET_MAPPED (socket))
- gtk_widget_map (widget);
-
- gtk_widget_queue_resize (widget);
- }
+ gtk_widget_set_parent (widget, GTK_WIDGET (socket));
g_signal_emit_by_name (G_OBJECT (socket), "plug_added", 0);
}
PRIVATE_GTK_IN_REPARENT = 1 << 6,
PRIVATE_GTK_DIRECTION_SET = 1 << 7, /* If the reading direction is not DIR_NONE */
PRIVATE_GTK_DIRECTION_LTR = 1 << 8, /* If the reading direction is DIR_LTR */
- PRIVATE_GTK_ANCHORED = 1 << 9 /* If widget has a GtkWindow ancestor */
+ PRIVATE_GTK_ANCHORED = 1 << 9, /* If widget has a GtkWindow ancestor */
+ PRIVATE_GTK_CHILD_VISIBLE = 1 << 10 /* If widget should be mapped when parent is mapped */
} GtkPrivateFlags;
/* Macros for extracting a widgets private_flags from GtkWidget.
#define GTK_WIDGET_DIRECTION_SET(obj) ((GTK_PRIVATE_FLAGS (obj) & PRIVATE_GTK_DIRECTION_SET) != 0)
#define GTK_WIDGET_DIRECTION_LTR(obj) ((GTK_PRIVATE_FLAGS (obj) & PRIVATE_GTK_DIRECTION_LTR) != 0)
#define GTK_WIDGET_ANCHORED(obj) ((GTK_PRIVATE_FLAGS (obj) & PRIVATE_GTK_ANCHORED) != 0)
+#define GTK_WIDGET_CHILD_VISIBLE(obj) ((GTK_PRIVATE_FLAGS (obj) & PRIVATE_GTK_CHILD_VISIBLE) != 0)
/* Macros for setting and clearing private widget flags.
* we use a preprocessor string concatenation here for a clear
guint arg_id);
static void gtk_scrolled_window_destroy (GtkObject *object);
static void gtk_scrolled_window_finalize (GObject *object);
-static void gtk_scrolled_window_map (GtkWidget *widget);
-static void gtk_scrolled_window_unmap (GtkWidget *widget);
static gint gtk_scrolled_window_expose (GtkWidget *widget,
GdkEventExpose *event);
static void gtk_scrolled_window_size_request (GtkWidget *widget,
object_class->get_arg = gtk_scrolled_window_get_arg;
object_class->destroy = gtk_scrolled_window_destroy;
- widget_class->map = gtk_scrolled_window_map;
- widget_class->unmap = gtk_scrolled_window_unmap;
widget_class->expose_event = gtk_scrolled_window_expose;
widget_class->size_request = gtk_scrolled_window_size_request;
widget_class->size_allocate = gtk_scrolled_window_size_allocate;
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-static void
-gtk_scrolled_window_map (GtkWidget *widget)
-{
- GtkScrolledWindow *scrolled_window;
-
- g_return_if_fail (GTK_IS_SCROLLED_WINDOW (widget));
-
- scrolled_window = GTK_SCROLLED_WINDOW (widget);
-
- /* chain parent class handler to map self and child */
- GTK_WIDGET_CLASS (parent_class)->map (widget);
-
- if (GTK_WIDGET_VISIBLE (scrolled_window->hscrollbar) &&
- !GTK_WIDGET_MAPPED (scrolled_window->hscrollbar))
- gtk_widget_map (scrolled_window->hscrollbar);
-
- if (GTK_WIDGET_VISIBLE (scrolled_window->vscrollbar) &&
- !GTK_WIDGET_MAPPED (scrolled_window->vscrollbar))
- gtk_widget_map (scrolled_window->vscrollbar);
-}
-
-static void
-gtk_scrolled_window_unmap (GtkWidget *widget)
-{
- GtkScrolledWindow *scrolled_window;
-
- g_return_if_fail (GTK_IS_SCROLLED_WINDOW (widget));
-
- scrolled_window = GTK_SCROLLED_WINDOW (widget);
-
- /* chain parent class handler to unmap self and child */
- GTK_WIDGET_CLASS (parent_class)->unmap (widget);
-
- if (GTK_WIDGET_MAPPED (scrolled_window->hscrollbar))
- gtk_widget_unmap (scrolled_window->hscrollbar);
-
- if (GTK_WIDGET_MAPPED (scrolled_window->vscrollbar))
- gtk_widget_unmap (scrolled_window->vscrollbar);
-}
-
static void
gtk_scrolled_window_paint (GtkWidget *widget,
GdkRectangle *area)
gtk_range_get_adjustment (GTK_RANGE (scrolled_window->vscrollbar))))
g_warning ("gtk_scrolled_window_add(): cannot add non scrollable widget "
"use gtk_scrolled_window_add_with_viewport() instead");
-
- if (GTK_WIDGET_REALIZED (child->parent))
- gtk_widget_realize (child);
-
- if (GTK_WIDGET_VISIBLE (child->parent) && GTK_WIDGET_VISIBLE (child))
- {
- if (GTK_WIDGET_MAPPED (child->parent))
- gtk_widget_map (child);
-
- gtk_widget_queue_resize (child);
- }
}
static void
static void gtk_table_class_init (GtkTableClass *klass);
static void gtk_table_init (GtkTable *table);
static void gtk_table_finalize (GObject *object);
-static void gtk_table_map (GtkWidget *widget);
-static void gtk_table_unmap (GtkWidget *widget);
static void gtk_table_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void gtk_table_size_allocate (GtkWidget *widget,
gobject_class->get_property = gtk_table_get_property;
gobject_class->set_property = gtk_table_set_property;
- widget_class->map = gtk_table_map;
- widget_class->unmap = gtk_table_unmap;
widget_class->size_request = gtk_table_size_request;
widget_class->size_allocate = gtk_table_size_allocate;
table->children = g_list_prepend (table->children, table_child);
gtk_widget_set_parent (child, GTK_WIDGET (table));
-
- if (GTK_WIDGET_REALIZED (child->parent))
- gtk_widget_realize (child);
-
- if (GTK_WIDGET_VISIBLE (child->parent) && GTK_WIDGET_VISIBLE (child))
- {
- if (GTK_WIDGET_MAPPED (child->parent))
- gtk_widget_map (child);
-
- gtk_widget_queue_resize (child);
- }
}
void
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-static void
-gtk_table_map (GtkWidget *widget)
-{
- GtkTable *table;
- GtkTableChild *child;
- GList *children;
-
- g_return_if_fail (GTK_IS_TABLE (widget));
-
- table = GTK_TABLE (widget);
- GTK_WIDGET_SET_FLAGS (table, GTK_MAPPED);
-
- children = table->children;
- while (children)
- {
- child = children->data;
- children = children->next;
-
- if (GTK_WIDGET_VISIBLE (child->widget) &&
- !GTK_WIDGET_MAPPED (child->widget))
- gtk_widget_map (child->widget);
- }
-}
-
-static void
-gtk_table_unmap (GtkWidget *widget)
-{
- GtkTable *table;
- GtkTableChild *child;
- GList *children;
-
- g_return_if_fail (GTK_IS_TABLE (widget));
-
- table = GTK_TABLE (widget);
- GTK_WIDGET_UNSET_FLAGS (table, GTK_MAPPED);
-
- children = table->children;
- while (children)
- {
- child = children->data;
- children = children->next;
-
- if (GTK_WIDGET_VISIBLE (child->widget) &&
- GTK_WIDGET_MAPPED (child->widget))
- gtk_widget_unmap (child->widget);
- }
-}
-
static void
gtk_table_size_request (GtkWidget *widget,
GtkRequisition *requisition)
gint y;
};
-static GtkTextViewChild* text_view_child_new_anchored (GtkWidget *child,
- GtkTextChildAnchor *anchor,
- GtkTextLayout *layout);
-static GtkTextViewChild* text_view_child_new_window (GtkWidget *child,
- GtkTextWindowType type,
- gint x,
- gint y);
-static void text_view_child_free (GtkTextViewChild *child);
-
-static void text_view_child_realize (GtkTextView *text_view,
- GtkTextViewChild *child);
+static GtkTextViewChild* text_view_child_new_anchored (GtkWidget *child,
+ GtkTextChildAnchor *anchor,
+ GtkTextLayout *layout);
+static GtkTextViewChild* text_view_child_new_window (GtkWidget *child,
+ GtkTextWindowType type,
+ gint x,
+ gint y);
+static void text_view_child_free (GtkTextViewChild *child);
+static void text_view_child_set_parent_window (GtkTextView *text_view,
+ GtkTextViewChild *child);
struct _GtkTextWindow
{
}
static void
-text_view_child_realize (GtkTextView *text_view,
- GtkTextViewChild *vc)
+text_view_child_set_parent_window (GtkTextView *text_view,
+ GtkTextViewChild *vc)
{
if (vc->anchor)
gtk_widget_set_parent_window (vc->widget,
vc->type);
gtk_widget_set_parent_window (vc->widget, window);
}
-
- gtk_widget_realize (vc->widget);
}
static void
text_view->children = g_slist_prepend (text_view->children,
vc);
- gtk_widget_set_parent (vc->widget, GTK_WIDGET (text_view));
-
if (GTK_WIDGET_REALIZED (text_view))
- text_view_child_realize (text_view, vc);
-
- if (GTK_WIDGET_VISIBLE (text_view) && GTK_WIDGET_VISIBLE (vc->widget))
- {
- if (GTK_WIDGET_MAPPED (text_view))
- gtk_widget_map (vc->widget);
-
- gtk_widget_queue_resize (vc->widget);
- }
+ text_view_child_set_parent_window (text_view, vc);
+
+ gtk_widget_set_parent (vc->widget, GTK_WIDGET (text_view));
}
void
GValue *value,
GParamSpec *pspec);
static void gtk_toolbar_destroy (GtkObject *object);
-static void gtk_toolbar_map (GtkWidget *widget);
-static void gtk_toolbar_unmap (GtkWidget *widget);
static gint gtk_toolbar_expose (GtkWidget *widget,
GdkEventExpose *event);
static void gtk_toolbar_size_request (GtkWidget *widget,
gobject_class->set_property = gtk_toolbar_set_property;
gobject_class->get_property = gtk_toolbar_get_property;
- widget_class->map = gtk_toolbar_map;
- widget_class->unmap = gtk_toolbar_unmap;
widget_class->expose_event = gtk_toolbar_expose;
widget_class->size_request = gtk_toolbar_size_request;
widget_class->size_allocate = gtk_toolbar_size_allocate;
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
-static void
-gtk_toolbar_map (GtkWidget *widget)
-{
- GtkToolbar *toolbar;
- GList *children;
- GtkToolbarChild *child;
-
- g_return_if_fail (GTK_IS_TOOLBAR (widget));
-
- toolbar = GTK_TOOLBAR (widget);
- GTK_WIDGET_SET_FLAGS (toolbar, GTK_MAPPED);
-
- for (children = toolbar->children; children; children = children->next)
- {
- child = children->data;
-
- if ((child->type != GTK_TOOLBAR_CHILD_SPACE)
- && GTK_WIDGET_VISIBLE (child->widget) && !GTK_WIDGET_MAPPED (child->widget))
- gtk_widget_map (child->widget);
- }
-}
-
-static void
-gtk_toolbar_unmap (GtkWidget *widget)
-{
- GtkToolbar *toolbar;
- GList *children;
- GtkToolbarChild *child;
-
- g_return_if_fail (GTK_IS_TOOLBAR (widget));
-
- toolbar = GTK_TOOLBAR (widget);
- GTK_WIDGET_UNSET_FLAGS (toolbar, GTK_MAPPED);
-
- for (children = toolbar->children; children; children = children->next)
- {
- child = children->data;
-
- if ((child->type != GTK_TOOLBAR_CHILD_SPACE)
- && GTK_WIDGET_VISIBLE (child->widget) && GTK_WIDGET_MAPPED (child->widget))
- gtk_widget_unmap (child->widget);
- }
-}
-
static void
gtk_toolbar_paint_space_line (GtkWidget *widget,
GdkRectangle *area,
toolbar->num_children++;
if (type != GTK_TOOLBAR_CHILD_SPACE)
- {
- gtk_widget_set_parent (child->widget, GTK_WIDGET (toolbar));
-
- if (GTK_WIDGET_REALIZED (child->widget->parent))
- gtk_widget_realize (child->widget);
-
- if (GTK_WIDGET_VISIBLE (child->widget->parent) && GTK_WIDGET_VISIBLE (child->widget))
- {
- if (GTK_WIDGET_MAPPED (child->widget->parent))
- gtk_widget_map (child->widget);
-
- gtk_widget_queue_resize (child->widget);
- }
- }
+ gtk_widget_set_parent (child->widget, GTK_WIDGET (toolbar));
else
gtk_widget_queue_resize (GTK_WIDGET (toolbar));
tree->children = g_list_insert (tree->children, tree_item, position);
gtk_widget_set_parent (tree_item, GTK_WIDGET (tree));
-
- if (GTK_WIDGET_REALIZED (tree_item->parent))
- gtk_widget_realize (tree_item);
-
- if (GTK_WIDGET_VISIBLE (tree_item->parent) && GTK_WIDGET_VISIBLE (tree_item))
- {
- if (GTK_WIDGET_MAPPED (tree_item->parent))
- gtk_widget_map (tree_item);
-
- gtk_widget_queue_resize (tree_item);
- }
}
static void
gtk_widget_set_parent (child, GTK_WIDGET (container));
- if (GTK_WIDGET_REALIZED (child->parent))
- gtk_widget_realize (child);
-
- if (GTK_WIDGET_VISIBLE (child->parent) && GTK_WIDGET_VISIBLE (child))
- {
- if (GTK_WIDGET_MAPPED (child->parent))
- gtk_widget_map (child);
-
- gtk_widget_queue_resize (child);
- }
-
if (!tree->selection && (tree->selection_mode == GTK_SELECTION_BROWSE))
gtk_tree_select_child (tree, child);
}
gtk_widget_hide (subtree);
gtk_widget_set_parent (subtree, GTK_WIDGET (tree_item)->parent);
-
- if (GTK_WIDGET_REALIZED (subtree->parent))
- gtk_widget_realize (subtree);
-
- if (GTK_WIDGET_VISIBLE (subtree->parent) && GTK_WIDGET_VISIBLE (subtree))
- {
- if (GTK_WIDGET_MAPPED (subtree->parent))
- gtk_widget_map (subtree);
-
- gtk_widget_queue_resize (subtree);
- }
}
void
gtk_widget_pop_composite_child ();
/* make sure we own a reference to it as well. */
- gtk_widget_set_parent (tree_column->button, GTK_WIDGET (tree_view));
if (tree_view->priv->header_window)
gtk_widget_set_parent_window (tree_column->button, tree_view->priv->header_window);
+ gtk_widget_set_parent (tree_column->button, GTK_WIDGET (tree_view));
gtk_signal_connect (GTK_OBJECT (tree_column->button), "realize",
(GtkSignalFunc) gtk_tree_view_column_button_realize,
static void gtk_viewport_set_scroll_adjustments (GtkViewport *viewport,
GtkAdjustment *hadjustment,
GtkAdjustment *vadjustment);
-static void gtk_viewport_map (GtkWidget *widget);
-static void gtk_viewport_unmap (GtkWidget *widget);
static void gtk_viewport_realize (GtkWidget *widget);
static void gtk_viewport_unrealize (GtkWidget *widget);
static void gtk_viewport_paint (GtkWidget *widget,
gobject_class->get_property = gtk_viewport_get_property;
object_class->destroy = gtk_viewport_destroy;
- widget_class->map = gtk_viewport_map;
- widget_class->unmap = gtk_viewport_unmap;
widget_class->realize = gtk_viewport_realize;
widget_class->unrealize = gtk_viewport_unrealize;
widget_class->expose_event = gtk_viewport_expose;
return viewport->shadow_type;
}
-static void
-gtk_viewport_map (GtkWidget *widget)
-{
- GtkBin *bin;
-
- g_return_if_fail (GTK_IS_VIEWPORT (widget));
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
- bin = GTK_BIN (widget);
-
- if (bin->child &&
- GTK_WIDGET_VISIBLE (bin->child) &&
- !GTK_WIDGET_MAPPED (bin->child))
- gtk_widget_map (bin->child);
-
- gdk_window_show (widget->window);
-}
-
-static void
-gtk_viewport_unmap (GtkWidget *widget)
-{
- g_return_if_fail (GTK_IS_VIEWPORT (widget));
-
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
-
- gdk_window_hide (widget->window);
-}
-
static void
gtk_viewport_realize (GtkWidget *widget)
{
{
GdkColormap *colormap;
- GTK_PRIVATE_FLAGS (widget) = 0;
+ GTK_PRIVATE_FLAGS (widget) = PRIVATE_GTK_CHILD_VISIBLE;
widget->state = GTK_STATE_NORMAL;
widget->saved_state = GTK_STATE_NORMAL;
widget->name = NULL;
if (GTK_WIDGET_REALIZED (widget) && !GTK_WIDGET_IN_REPARENT (widget))
gtk_widget_unrealize (widget);
+ /* Removing a widget from a container restores the child visible
+ * flag to the default state, so it doesn't affect the child
+ * in the next parent.
+ */
+ GTK_PRIVATE_SET_FLAG (widget, GTK_CHILD_VISIBLE);
+
old_parent = widget->parent;
widget->parent = NULL;
gtk_widget_set_parent_window (widget, NULL);
if (widget->parent &&
GTK_WIDGET_MAPPED (widget->parent) &&
+ GTK_WIDGET_CHILD_VISIBLE (widget) &&
!GTK_WIDGET_MAPPED (widget))
gtk_widget_map (widget);
}
gtk_widget_map (GtkWidget *widget)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- g_return_if_fail (GTK_WIDGET_VISIBLE (widget) == TRUE);
+ g_return_if_fail (GTK_WIDGET_VISIBLE (widget));
+ g_return_if_fail (GTK_WIDGET_CHILD_VISIBLE (widget));
if (!GTK_WIDGET_MAPPED (widget))
{
if (GTK_WIDGET_ANCHORED (widget->parent))
_gtk_widget_propagate_hierarchy_changed (widget, NULL);
g_object_notify (G_OBJECT (widget), "parent");
+
+ /* Enforce realized/mapped invariants
+ */
+ if (GTK_WIDGET_REALIZED (widget->parent))
+ gtk_widget_realize (widget);
+
+ if (GTK_WIDGET_VISIBLE (widget->parent) &&
+ GTK_WIDGET_VISIBLE (widget))
+ {
+ if (GTK_WIDGET_CHILD_VISIBLE (widget) &&
+ GTK_WIDGET_MAPPED (widget->parent))
+ gtk_widget_map (widget);
+
+ gtk_widget_queue_resize (widget);
+ }
}
/**
}
}
+
+/**
+ * gtk_widget_set_child_visible:
+ * @widget: a #GtkWidget
+ * @is_visible: if %TRUE, @widget should be mapped along with its parent.
+ *
+ * Sets whether @widget should be mapped along with its when its parent
+ * is mapped and @widget has been shown with gtk_widget_show().
+ *
+ * The child visibility can be set for widget before it is added to
+ * a container with gtk_widget_set_parent(), to avoid mapping
+ * children unnecessary before immediately unmapping them. However
+ * it will be reset to its default state of %TRUE when the widget
+ * is removed from a container.
+ *
+ * Note that changing the child visibility of a widget does not
+ * queue a resize on the widget. Most of the time, the size of
+ * a widget is computed from all visible children, whether or
+ * not they are mapped. If this is not the case, the container
+ * can queue a resize itself.
+ *
+ * This function is only useful for container implementations and
+ * never should be called by an application.
+ **/
+void
+gtk_widget_set_child_visible (GtkWidget *widget,
+ gboolean is_visible)
+{
+ gboolean was_visible;
+
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ was_visible = GTK_WIDGET_CHILD_VISIBLE (widget);
+ is_visible = is_visible != FALSE;
+
+ if (is_visible != was_visible)
+ {
+ if (is_visible)
+ {
+ GTK_PRIVATE_SET_FLAG (widget, GTK_CHILD_VISIBLE);
+
+ if (widget->parent &&
+ GTK_WIDGET_VISIBLE (widget->parent) &&
+ GTK_WIDGET_VISIBLE (widget))
+ {
+ if (GTK_WIDGET_MAPPED (widget->parent))
+ gtk_widget_map (widget);
+ }
+ }
+ else
+ {
+ GTK_PRIVATE_UNSET_FLAG (widget, GTK_CHILD_VISIBLE);
+
+ if (GTK_WIDGET_MAPPED (widget))
+ gtk_widget_unmap (widget);
+ }
+ }
+}
+
+/**
+ * gtk_widget_get_child_visible:
+ * @widget: a #GtkWidget
+ *
+ * Gets the value set with gtk_widget_set_child_visible().
+ * If you feel a need to use this function, your code probably
+ * needs reorganization.
+ *
+ * This function is only useful for container implementations and
+ * never should be called by an application.
+ *
+ * Return value: %TRUE if the widget is mapped with the parent.
+ **/
+gboolean
+gtk_widget_get_child_visible (GtkWidget *widget)
+{
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ return GTK_WIDGET_CHILD_VISIBLE (widget);
+}
+
/*************************************************************
* gtk_widget_get_parent_window:
* Get widget's parent window
g_object_ref (G_OBJECT (accessible));
return accessible;
}
+
GtkWidget *parent);
void gtk_widget_set_parent_window (GtkWidget *widget,
GdkWindow *parent_window);
+void gtk_widget_set_child_visible (GtkWidget *widget,
+ gboolean is_visible);
+gboolean gtk_widget_get_child_visible (GtkWidget *widget);
+
GtkWidget *gtk_widget_get_parent (GtkWidget *widget);
GdkWindow *gtk_widget_get_parent_window (GtkWidget *widget);
gboolean gtk_widget_child_focus (GtkWidget *widget,